package cn.sinjet.model.carassist;

import com.mgroup.wazehelper.R;

import android.content.SharedPreferences;
import cn.sinjet.viewmodel.ViewModel;

public class Settings {
    public boolean bAutoOpenBT = true;
    public boolean bAutoOpenGps = true;
    public boolean isKeepScreenOn = true;
    
    public int dayNightMode = 0;
    public boolean isTrafficVoiceOn = true;
    public boolean isNaviVoiceOn = true;
    public int speedAjust = 0;
    
    public int mCongestion = 1;
    public int mAvoidHighSpeed = 0;
    public int mCost = 0;
    public int mHighSpeed = 1;
    
    public int mTempVoiceOn = 1;
    public int mVoltageVoiceOn = 1;
    public int mTpmsVoiceOn = 1;
    public int mHandbrakeVoiceOn = 1;
    public int mSeatbeltVoiceOn = 1;
    public int mDoorVoiceOn = 1;
    
	public void initUI() {
		// TODO Auto-generated method stub
		ViewModel.getIns().setViewProperty(R.id.bt_auto_open, (int)((bAutoOpenBT)?1:0));
    	ViewModel.getIns().setViewProperty(R.id.gps_auto_open, (int)((bAutoOpenGps)?1:0));
    	ViewModel.getIns().setViewProperty(R.id.keep_screen_on, (int)((isKeepScreenOn)?1:0));
    	ViewModel.getIns().setViewProperty(R.id.navi_set_navi_voice, (int)((isNaviVoiceOn)?1:0));
    	ViewModel.getIns().setViewProperty(R.id.navi_set_traffic_voice, (int)((isTrafficVoiceOn)?1:0));
    	ViewModel.getIns().setViewProperty(R.id.navi_strategy_avoid_highspeed, mAvoidHighSpeed);
    	ViewModel.getIns().setViewProperty(R.id.navi_strategy_highspeed, mHighSpeed);
    	ViewModel.getIns().setViewProperty(R.id.navi_strategy_cost, mCost);
    	ViewModel.getIns().setViewProperty(R.id.navi_strategy_congestion, mCongestion);
    	ViewModel.getIns().setViewProperty(R.id.temperature_voice_on, mTempVoiceOn);
    	ViewModel.getIns().setViewProperty(R.id.voltage_voice_on, mVoltageVoiceOn);
    	ViewModel.getIns().setViewProperty(R.id.tpms_voice_on, mTpmsVoiceOn);
    	ViewModel.getIns().setViewProperty(R.id.handbrake_voice_on, mHandbrakeVoiceOn);
    	ViewModel.getIns().setViewProperty(R.id.seatbelt_voice_on, mSeatbeltVoiceOn);
    	ViewModel.getIns().setViewProperty(R.id.doors_voice_on, mDoorVoiceOn);
    	
		String[] dayNightModeStr = new String[]{"自动模式","白天模式","夜间模式"};
		if(dayNightMode<3) ViewModel.getIns().setViewProperty(R.id.navi_set_day_night_mode_value, dayNightModeStr[dayNightMode]);
	 }   	
     public void storeSettings(SharedPreferences.Editor editor){
         editor.putBoolean("bAutoOpenBT", bAutoOpenBT);
         editor.putBoolean("bAutoOpenGps", bAutoOpenGps);
         editor.putBoolean("bKeepScreenOn", isKeepScreenOn);
         editor.putBoolean("isTrafficVoiceOn", isTrafficVoiceOn);
         editor.putBoolean("isNaviVoiceOn", isNaviVoiceOn);
         editor.putInt("dayNightMode", dayNightMode);
         editor.putInt("mCongestion", mCongestion);
         editor.putInt("mAvoidHighSpeed", mAvoidHighSpeed);
         editor.putInt("mCost", mCost);
         editor.putInt("mHighSpeed", mHighSpeed);
         editor.putInt("mTempVoiceOn", mTempVoiceOn);
         editor.putInt("mVoltageVoiceOn", mVoltageVoiceOn);
         editor.putInt("mTpmsVoiceOn", mTpmsVoiceOn);
         editor.putInt("mHandbrakeVoiceOn", mHandbrakeVoiceOn);
         editor.putInt("mSeatbeltVoiceOn", mSeatbeltVoiceOn);
         editor.putInt("mDoorVoiceOn", mDoorVoiceOn);
         editor.commit();
     }
     public void restoreSettings(SharedPreferences sp){
    	 bAutoOpenBT = sp.getBoolean("bAutoOpenBT", true);
    	 bAutoOpenGps = sp.getBoolean("bAutoOpenGps", true);
    	 isKeepScreenOn = sp.getBoolean("bKeepScreenOn", true);
    	 isTrafficVoiceOn = sp.getBoolean("isTrafficVoiceOn", true);
    	 isNaviVoiceOn = sp.getBoolean("isNaviVoiceOn", true);
    	 dayNightMode = sp.getInt("dayNightMode", 0);
    	 mCongestion = sp.getInt("mCongestion", 1);
    	 mAvoidHighSpeed = sp.getInt("mAvoidHighSpeed", 0);
    	 mHighSpeed = sp.getInt("mHighSpeed", 1);
    	 mCost = sp.getInt("mCost", 0);
    	 mTempVoiceOn = sp.getInt("mTempVoiceOn", 1);
    	 mVoltageVoiceOn = sp.getInt("mVoltageVoiceOn", 1);
    	 mTpmsVoiceOn = sp.getInt("mTpmsVoiceOn", 1);
    	 mHandbrakeVoiceOn = sp.getInt("mHandbrakeVoiceOn", 1);
    	 mSeatbeltVoiceOn = sp.getInt("mSeatbeltVoiceOn", 1);
    	 mDoorVoiceOn = sp.getInt("mDoorVoiceOn", 1);
     }
}
